myApp.controller('position', ['$scope', '$http', function($scope, $http){

	$scope.name = "";
	$scope.description = "";

	$scope.addPosition = function() {

		if($scope.name === "") {
			alert("请填写名称！");
			return;
		}
		if($scope.description === "") {
			alert("请填写描述！");
			return;
		}

		var positionData = {
			"position.name": $scope.name,
			"position.description": $scope.description, 
		};

		var postCfg = {
			headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
			transformRequest: function (data) {
				return $.param(data);
			}
		};

		$http.post('addPosition', positionData, postCfg).then(function successCallback(response) {
			alert("已添加成功！");
			$scope.name = "";
			$scope.description = "";

			console.log("ok：" + response);
		}, function errorCallback(response) {
			alert("添加操作失败！");
			console.log("fail：" + response);
		});


	};


}]);